package cn.javass.dp.chianofresponsibility.example5;

public class GeneralManager extends Handle {

    @Override
    public Object handleRequest(RequestModel rm) {
        if (FeeRequestModel.FEE_TYPE.equals(rm.getType())) {
            //表示聚餐费用申请
            return handleFeeRequest(rm);
        } else {
            //
            return super.handleRequest(rm);
        }
    }

    public Object handleFeeRequest(RequestModel rm) {
        FeeRequestModel frm = (FeeRequestModel) rm;
        String str = "";
        if (frm.getFee() >= 1000) {
            if ("小李".equals(frm.getUser())) {
                str = "总经理同意" + frm.getUser() + "聚餐费用" + frm.getFee() + "请求";
            } else {
                str = "总经理不！！！同意" + frm.getUser() + "聚餐费用" + frm.getFee() + "请求";

            }
        } else {
            if (this.successor != null) {
                return successor.handleRequest(rm);
            }
        }
        return str;
    }

   /* @Override
    public boolean handlePreFeeRequest(String user, double requestNum) {
        if (requestNum >= 5000) {
            System.out.println("总经理同意"+user+"预支差旅费"+requestNum+"元");
            return true;
        } else {
            if (successor != null) {
                return this.successor.handlePreFeeRequest(user, requestNum);
            }
        }
        return false;
    }*/
}
